<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>注释 - cppreference.com</title>
<meta charset="UTF-8" />
<meta name="generator" content="MediaWiki 1.21.2" />
<link rel="alternate" type="application/x-wiki" title="编辑" href="/mwiki/index.php?title=cpp/comment&amp;action=edit" />
<link rel="edit" title="编辑" href="/mwiki/index.php?title=cpp/comment&amp;action=edit" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="/mwiki/opensearch_desc.php" title="cppreference.com (zh)" />
<link rel="EditURI" type="application/rsd+xml" href="https://zh.cppreference.com/mwiki/api.php?action=rsd" />
<link rel="alternate" hreflang="zh" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh" />
<link rel="alternate" hreflang="zh-hans" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-hans" />
<link rel="alternate" hreflang="zh-hant" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-hant" />
<link rel="alternate" hreflang="zh-cn" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-cn" />
<link rel="alternate" hreflang="zh-hk" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-hk" />
<link rel="alternate" hreflang="zh-mo" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-mo" />
<link rel="alternate" hreflang="zh-my" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-my" />
<link rel="alternate" hreflang="zh-sg" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-sg" />
<link rel="alternate" hreflang="zh-tw" href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-tw" />
<link rel="alternate" type="application/atom+xml" title="cppreference.com的Atom" href="/mwiki/index.php?title=Special:%E6%9C%80%E8%BF%91%E6%9B%B4%E6%94%B9&amp;feed=atom" />
<link rel="stylesheet" href="https://zh.cppreference.com/mwiki/load.php?debug=false&amp;lang=zh&amp;modules=ext.gadget.ColiruCompiler%2CMathJax%7Cext.rtlcite%7Cmediawiki.legacy.commonPrint%2Cshared%7Cskins.cppreference2&amp;only=styles&amp;skin=cppreference2&amp;*" />
<meta name="ResourceLoaderDynamicStyles" content="" />
<link rel="stylesheet" href="https://zh.cppreference.com/mwiki/load.php?debug=false&amp;lang=zh&amp;modules=site&amp;only=styles&amp;skin=cppreference2&amp;*" />
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="https://zh.cppreference.com/mwiki/load.php?debug=false&amp;lang=zh&amp;modules=startup&amp;only=scripts&amp;skin=cppreference2&amp;*"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/comment","wgTitle":"cpp/comment","wgCurRevisionId":91429,"wgArticleId":1567,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/comment","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_comment skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <div id="mw-head" class="noprint">
            <div id="cpp-head-first-base">
                <div id="cpp-head-first">
                    <h5><a href="/">
                        cppreference.com                        </a></h5>
                    <div id="cpp-head-search">
                        
<!-- 0 -->
<div id="p-search">
<form action="https://duckduckgo.com/" method="get">
  <input type="hidden" name="sites" value="cppreference.com">
  <input type="search" name="q">
  <input type="submit" value="Search">
</form>
</div>

<!-- /0 -->
                    </div>
                    <div id="cpp-head-personal">
                        
<!-- 0 -->
<div id="p-personal" class="">
<span id="pt-createaccount"><a href="/mwiki/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95&amp;returnto=cpp%2Fcomment&amp;type=signup">创建账户</a></span>	<div class="menu">
        <ul>
<li id="pt-login"><a href="/mwiki/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95&amp;returnto=cpp%2Fcomment" title="我们鼓励你登录，不过这不是强制的 [o]" accesskey="o">登录</a></li>        </ul>
    </div>
</div>

<!-- /0 -->
                    </div>

                </div>
            </div>
            <div id="cpp-head-second-base">
                <div id="cpp-head-second">
                    <div id="cpp-head-tools-left">
                        
<!-- 0 -->
<div id="p-namespaces" class="vectorTabs">
	<h5>名字空间</h5>
	<ul>
					<li  id="ca-nstab-main" class="selected"><span><a href="/w/cpp/comment"  title="查看内容页面 [c]" accesskey="c">页面</a></span></li>
					<li  id="ca-talk" class="new"><span><a href="/mwiki/index.php?title=Talk:cpp/comment&amp;action=edit&amp;redlink=1"  title="有关内容页面的讨论 [t]" accesskey="t">讨论</a></span></li>
			</ul>
</div>

<!-- /0 -->

<!-- 1 -->
<div id="p-variants" class="vectorMenu">
		<h5><span>变换</span><a href="#"></a></h5>
	<div class="menu">
		<ul>
							<li id="ca-varlang-0" class="selected"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh" >不转换</a></li>
							<li id="ca-varlang-1"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-hans" >简体</a></li>
							<li id="ca-varlang-2"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-hant" >繁體</a></li>
							<li id="ca-varlang-3"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-cn" >大陆简体</a></li>
							<li id="ca-varlang-4"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-hk" >香港繁體</a></li>
							<li id="ca-varlang-5"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-mo" >澳門繁體</a></li>
							<li id="ca-varlang-6"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-my" >大马简体</a></li>
							<li id="ca-varlang-7"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-sg" >新加坡简体</a></li>
							<li id="ca-varlang-8"><a href="/mwiki/index.php?title=cpp/comment&amp;variant=zh-tw" >台灣正體</a></li>
					</ul>
	</div>
</div>

<!-- /1 -->
                    </div>
                    <div id="cpp-head-tools-right">
                        
<!-- 0 -->
<div id="p-views" class="vectorTabs">
	<h5>查看</h5>
	<ul>
					<li id="ca-view" class="selected"><span><a href="/w/cpp/comment" >查看</a></span></li>
					<li id="ca-edit"><span><a href="/mwiki/index.php?title=cpp/comment&amp;action=edit"  title="你可以编辑本页面。请在保存前使用预览按钮。 [e]" accesskey="e">编辑</a></span></li>
					<li id="ca-history" class="collapsible"><span><a href="/mwiki/index.php?title=cpp/comment&amp;action=history"  title="本页面过去的版本 [h]" accesskey="h">历史</a></span></li>
			</ul>
</div>

<!-- /0 -->

<!-- 1 -->
<div id="p-cactions" class="vectorMenu emptyPortlet">
	<h5><span>操作</span><a href="#"></a></h5>
	<div class="menu">
		<ul>
					</ul>
	</div>
</div>

<!-- /1 -->
                    </div>
                </div>
            </div>
        </div>
        <!-- /header -->
        <!-- content -->
<style type="text/css">
#carbonads {
  display: block;
  overflow: hidden;
  position: absolute;
  text-align: center;
  left: -170px;
  max-width: 150px;
  border-radius: 4px;
  border: solid 1px hsla(0, 0%, 0%, .1);
  background-color: hsl(0, 0%, 98%);
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu,
  Cantarell, "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

#carbonads a {
  color: inherit;
  text-decoration: none;
}

#carbonads a:hover {
  color: inherit;
}

#carbonads span {
  position: relative;
  display: block;
  overflow: hidden;
}

.carbon-img {
  display: block;
  margin-bottom: 8px;
  max-width: 150px;
  line-height: 1;
}

.carbon-img img {
  display: block;
  margin: 0 auto;
  max-width: 150px !important;
  width: 150px;
  height: auto;
}

.carbon-text {
  display: block;
  padding: 0 1em 8px;
}

.carbon-poweredby {
  display: block;
  padding: 8px 12px;
  background: repeating-linear-gradient(-45deg, transparent, transparent 5px, hsla(0, 0%, 0%, .025) 5px, hsla(0, 0%, 0%, .025) 10px) hsla(203, 11%, 95%, .4);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
  font-size: 9px;
  line-height: 1;
}
html { font-variant-ligatures: no-common-ligatures; }
</style>
        <div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CKYITK7M&placement=cppreferencecom" id="_carbonads_js"></script>

<script async src="https://www.googletagmanager.com/gtag/js?id=G-8HW0LXMYCY"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-8HW0LXMYCY');
</script>
                <h1 id="firstHeading" class="firstHeading">注释</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="/w/cpp" title="cpp">cpp</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><p><br />
</p>
<div class="t-navbar" style=""><div class="t-navbar-sep">&#160;</div><div class="t-navbar-head"><a href="/w/cpp" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/compiler_support" title="cpp/compiler support"> 编译器支持</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/freestanding" title="cpp/freestanding"> 自立实现与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/language" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/standard_library" title="cpp/standard library">标准库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/header" title="cpp/header">标准库标头</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/named_req" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/feature_test" title="cpp/feature test"> 功能特性测试宏 </a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/utility#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/concepts" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/meta" title="cpp/meta"> 元编程库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/error" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/utility" title="cpp/utility">通用工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/string" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/iterator" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/ranges" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/algorithm" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/numeric" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/locale" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/io" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/filesystem" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/regex" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/thread" title="cpp/thread">并发支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/execution" title="cpp/execution">执行支持库</a> <span class="t-mark-rev t-since-cxx26">(C++26)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/experimental" title="cpp/experimental">技术规范</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/symbol_index" title="cpp/symbol index"> 符号索引</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="/w/cpp/links/libs" title="cpp/links/libs"> 外部库</a> </td></tr>
</table></div><div><span class="editsection noprint plainlinks" title="编辑此模板"><a rel="nofollow" class="external text" href="https://zh.cppreference.com/mwiki/index.php?title=Template:cpp/navbar_content&amp;action=edit">&#91;编辑&#93;</a></span></div></div></div></div><div class="t-navbar-sep">&#160;</div><div class="t-navbar-head"><a href="/w/cpp/language" title="cpp/language">C++ 语言</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5">一般主题</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/preprocessor" title="cpp/preprocessor">预处理器</a></td></tr>
<tr class="t-nv"><td colspan="5"><strong class="selflink">注释</strong></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/keyword" title="cpp/keyword">关键词</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/escape" title="cpp/language/escape">转义序列</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"><a href="/w/cpp/language/statements" title="cpp/language/statements">流程控制</a></td></tr>
<tr class="t-nv-h2"><td colspan="5">条件执行语句</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/if" title="cpp/language/if"><tt>if</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/switch" title="cpp/language/switch"><tt>switch</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">重复语句（循环）</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/for" title="cpp/language/for"><tt>for</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/range-for" title="cpp/language/range-for">范围 <span class="mw-geshi cpp source-cpp"><span class="kw1">for</span></span></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/while" title="cpp/language/while"><tt>while</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/do" title="cpp/language/do"><code>do-while</code></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">跳转语句</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/continue" title="cpp/language/continue"><tt>continue</tt></a> - <a href="/w/cpp/language/break" title="cpp/language/break"><tt>break</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/goto" title="cpp/language/goto"><tt>goto</tt></a> - <a href="/w/cpp/language/return" title="cpp/language/return"><tt>return</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"><a href="/w/cpp/language/functions" title="cpp/language/functions">函数</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/function" title="cpp/language/function">函数声明</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/lambda" title="cpp/language/lambda">lambda 函数表达式</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/inline" title="cpp/language/inline"><span class="mw-geshi cpp source-cpp"><span class="kw1">inline</span></span> 说明符</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/except_spec" title="cpp/language/except spec">动态异常说明</a> <span class="t-mark" style="white-space: nowrap;">(<span title="C++11 中弃用">C++17 前*</span>)</span></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/noexcept_spec" title="cpp/language/noexcept spec"><span class="mw-geshi cpp source-cpp"><span class="kw1">noexcept</span></span> 说明符</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5">异常</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/throw" title="cpp/language/throw"><span class="mw-geshi cpp source-cpp"><span class="kw1">throw</span></span> 表达式</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/try" title="cpp/language/try"><span class="mw-geshi cpp source-cpp"><span class="kw1">try</span></span> 块</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br />
</td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/catch" title="cpp/language/catch">处理块</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5">命名空间</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/namespace" title="cpp/language/namespace">命名空间声明</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/namespace_alias" title="cpp/language/namespace alias">命名空间别名</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5">类型</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/types" title="cpp/language/types">基础类型</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/enum" title="cpp/language/enum">枚举类型</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/function" title="cpp/language/function">函数类型</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/class" title="cpp/language/class">类/结构体类型</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/union" title="cpp/language/union">联合体类型</a></td></tr>
<tr class="t-nv"><td colspan="5"> <br />
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">说明符</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/cv" title="cpp/language/cv"><span class="mw-geshi cpp source-cpp"><span class="kw4">const</span></span>/<span class="mw-geshi cpp source-cpp"><span class="kw4">volatile</span></span></a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/decltype" title="cpp/language/decltype"><tt>decltype</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span>&#160;&#160;</td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/auto" title="cpp/language/auto"><tt>auto</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/constexpr" title="cpp/language/constexpr"><tt>constexpr</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span>&#160;&#160;</td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/consteval" title="cpp/language/consteval"><tt>consteval</tt></a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/constinit" title="cpp/language/constinit"><tt>constinit</tt></a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/storage_duration" title="cpp/language/storage duration">存储期说明符</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"><a href="/w/cpp/language/initialization" title="cpp/language/initialization">初始化</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/default_initialization" title="cpp/language/default initialization">默认初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/value_initialization" title="cpp/language/value initialization">值初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/zero_initialization" title="cpp/language/zero initialization">零初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/copy_initialization" title="cpp/language/copy initialization">复制初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/direct_initialization" title="cpp/language/direct initialization">直接初始化</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/aggregate_initialization" title="cpp/language/aggregate initialization">聚合初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/list_initialization" title="cpp/language/list initialization">列表初始化</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/constant_initialization" title="cpp/language/constant initialization">常量初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/reference_initialization" title="cpp/language/reference initialization">引用初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <br />
</td></tr>
</table></div></td></tr>
</table></div>
</div>
<div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"><a href="/w/cpp/language/expressions" title="cpp/language/expressions">表达式</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/value_category" title="cpp/language/value category">值类别</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/eval_order" title="cpp/language/eval order">求值顺序</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/operators" title="cpp/language/operators">运算符</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/operator_precedence" title="cpp/language/operator precedence">运算符优先级</a></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/operator_alternative" title="cpp/language/operator alternative">替代表示</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"><a href="/w/cpp/language/expressions#.E5.AD.97.E9.9D.A2.E9.87.8F" title="cpp/language/expressions">字面量</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/bool_literal" title="cpp/language/bool literal">布尔</a> - <a href="/w/cpp/language/integer_literal" title="cpp/language/integer literal">整数</a> - <a href="/w/cpp/language/floating_literal" title="cpp/language/floating literal">浮点</a></td></tr>   
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/character_literal" title="cpp/language/character literal">字符</a> - <a href="/w/cpp/language/string_literal" title="cpp/language/string literal">字符串</a> - <a href="/w/cpp/language/nullptr" title="cpp/language/nullptr"><tt>nullptr</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr> 
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/user_literal" title="cpp/language/user literal">用户定义</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5">工具</td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/attributes" title="cpp/language/attributes">属性</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5">类型</td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/typedef" title="cpp/language/typedef"><code>typedef</code> 声明</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/type_alias" title="cpp/language/type alias">类型别名声明</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5">类型转换</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/implicit_conversion" title="cpp/language/implicit conversion">隐式转换</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/static_cast" title="cpp/language/static cast"><tt>static_cast</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/const_cast" title="cpp/language/const cast"><tt>const_cast</tt></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/explicit_cast" title="cpp/language/explicit cast">显式转换</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/dynamic_cast" title="cpp/language/dynamic cast"><tt>dynamic_cast</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/reinterpret_cast" title="cpp/language/reinterpret cast"><tt>reinterpret_cast</tt></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">内存分配</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/new" title="cpp/language/new"><code>new</code> 表达式</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/delete" title="cpp/language/delete"><code>delete</code> 表达式</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"><a href="/w/cpp/language/classes" title="cpp/language/classes">类</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/class" title="cpp/language/class">类声明</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/constructor" title="cpp/language/constructor">构造函数</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/this" title="cpp/language/this"><code>this</code> 指针</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/access" title="cpp/language/access">访问说明符</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/friend" title="cpp/language/friend"><span class="mw-geshi cpp source-cpp"><span class="kw1">friend</span></span> 说明符</a></td></tr>
<tr class="t-nv"><td colspan="5"> <br />
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">类特有的函数性质</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/virtual" title="cpp/language/virtual">虚函数</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/override" title="cpp/language/override"><span class="mw-geshi cpp source-cpp">override</span> 说明符</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span>&#160;&#160;</td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/final" title="cpp/language/final"><span class="mw-geshi cpp source-cpp">final</span> 说明符</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/explicit" title="cpp/language/explicit"><tt>explicit</tt></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/static" title="cpp/language/static"><tt>static</tt></a></td></tr>
<tr class="t-nv"><td colspan="5"> <br />
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5">特殊成员函数</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/default_constructor" title="cpp/language/default constructor">默认构造函数</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/copy_constructor" title="cpp/language/copy constructor">复制构造函数</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/move_constructor" title="cpp/language/move constructor">移动构造函数</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/copy_assignment" title="cpp/language/copy assignment">复制赋值</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/move_assignment" title="cpp/language/move assignment">移动赋值</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/destructor" title="cpp/language/destructor">析构函数</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"><a href="/w/cpp/language/templates" title="cpp/language/templates">模板</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/class_template" title="cpp/language/class template">类模板</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/function_template" title="cpp/language/function template">函数模板</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/template_specialization" title="cpp/language/template specialization">模板特化</a></td></tr>   
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/parameter_pack" title="cpp/language/parameter pack">形参包</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5">杂项</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/asm" title="cpp/language/asm">内联汇编</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/history" title="cpp/language/history">C++ 的历史</a></td></tr>
</table></div></td></tr>
</table></div>
</div><div><span class="editsection noprint plainlinks" title="编辑此模板"><a rel="nofollow" class="external text" href="https://zh.cppreference.com/mwiki/index.php?title=Template:cpp/language/navbar_content&amp;action=edit">&#91;编辑&#93;</a></span></div></div></div></div><div class="t-navbar-sep">&#160;</div><div class="t-navbar-head"><a href="/w/cpp/language/basic_concepts" title="cpp/language/basic concepts">基本概念</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><strong class="selflink">注释</strong></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/ascii" title="cpp/language/ascii">ASCII</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/punctuators" title="cpp/language/punctuators">标点</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/identifiers" title="cpp/language/identifiers">名字和标识符</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/type" title="cpp/language/type">类型</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/types" title="cpp/language/types">基础类型</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/object" title="cpp/language/object">对象</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/scope" title="cpp/language/scope">作用域</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/lifetime" title="cpp/language/lifetime">对象生存期</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/storage_duration" title="cpp/language/storage duration">存储期与链接</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/definition" title="cpp/language/definition">定义和单一定义规则（ODR）</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/lookup" title="cpp/language/lookup">名字查找</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/qualified_lookup" title="cpp/language/qualified lookup">有限定名字查找</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/unqualified_lookup" title="cpp/language/unqualified lookup">无限定名字查找</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/as_if" title="cpp/language/as if">“如同”规则</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/ub" title="cpp/language/ub">未定义行为</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/memory_model" title="cpp/language/memory model">内存模型</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/multithread" title="cpp/language/multithread">多线程执行与数据竞争</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/charset" title="cpp/language/charset">字符集与编码</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/translation_phases" title="cpp/language/translation phases">翻译阶段</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/main_function" title="cpp/language/main function"><code>main()</code> 函数</a></td></tr>
<tr class="t-nv"><td colspan="5"><a href="/w/cpp/language/modules" title="cpp/language/modules">模块</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span></td></tr>
</table></div>
</div><div><span class="editsection noprint plainlinks" title="编辑此模板"><a rel="nofollow" class="external text" href="https://zh.cppreference.com/mwiki/index.php?title=Template:cpp/language/basics/navbar_content&amp;action=edit">&#91;编辑&#93;</a></span></div></div></div></div><div class="t-navbar-sep">&#160;</div></div>
<p>注释是一种代码内文档。当被插入到程序中时，它们实际上会被编译器忽略；它们只需要被阅读源代码的人当作注记。虽然具体的文档并不是 C++ 标准的一部分，但一些工具可以解析各式注释。
</p>
<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>目录</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#.E8.AF.AD.E6.B3.95"><span class="tocnumber">1</span> <span class="toctext">语法</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#C_.E9.A3.8E.E6.A0.BC"><span class="tocnumber">2</span> <span class="toctext">C 风格</span></a></li>
<li class="toclevel-1 tocsection-3"><a href="#C.2B.2B_.E9.A3.8E.E6.A0.BC"><span class="tocnumber">3</span> <span class="toctext">C++ 风格</span></a></li>
<li class="toclevel-1 tocsection-4"><a href="#.E6.B3.A8.E8.A7.A3"><span class="tocnumber">4</span> <span class="toctext">注解</span></a></li>
<li class="toclevel-1 tocsection-5"><a href="#.E7.A4.BA.E4.BE.8B"><span class="tocnumber">5</span> <span class="toctext">示例</span></a></li>
<li class="toclevel-1 tocsection-6"><a href="#.E5.8F.82.E9.98.85"><span class="tocnumber">6</span> <span class="toctext">参阅</span></a></li>
</ul>
</td></tr></table>
<h3><span class="editsection">[<a href="/mwiki/index.php?title=cpp/comment&amp;action=edit&amp;section=1" title="编辑章节：语法">编辑</a>]</span> <span class="mw-headline" id=".E8.AF.AD.E6.B3.95">语法</span></h3>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>/*</b></code> <span class="t-spar">注释内容</span> <code><b>*/</b></code>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>//</b></code> <span class="t-spar">注释内容</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr></table>
<div class="t-li1"><span class="t-li">1)</span> 通称为“C 风格”或“多行”注释。</div>
<div class="t-li1"><span class="t-li">2)</span> 通称为“C++ 风格”或“单行”注释。</div>
<p>在<a href="/w/cpp/language/translation_phases#.E9.98.B6.E6.AE.B5_3" title="cpp/language/translation phases">翻译阶段 3</a> 中，每段注释通过被替换为单个空白字符从程序中移除。
</p>
<h3><span class="editsection">[<a href="/mwiki/index.php?title=cpp/comment&amp;action=edit&amp;section=2" title="编辑章节：C 风格">编辑</a>]</span> <span class="mw-headline" id="C_.E9.A3.8E.E6.A0.BC">C 风格</span></h3>
<p>C 风格注释通常用于注释大块的文本，也可以用于注释单行文本。要插入一个 C 风格注释，可以简单地以 <code><b>/*</b></code> 和 <code><b>*/</b></code> 环绕文本；这样会使注释的内容被编译器忽略。尽管不是 C++ 标准的一部分，<code><b>/**</b></code> 和 <code><b>*/</b></code> 常用于指示文档块；这是合法的，因为第二个星号简单地被当做注释的一部分。C风格注释不能嵌套。
</p>
<h3><span class="editsection">[<a href="/mwiki/index.php?title=cpp/comment&amp;action=edit&amp;section=3" title="编辑章节：C++ 风格">编辑</a>]</span> <span class="mw-headline" id="C.2B.2B_.E9.A3.8E.E6.A0.BC">C++ 风格</span></h3>
<p>C++ 风格注释通常用于注释单行文本；不过也可以把多个 C++ 风格注释放在一起来组成多行注释。C++ 风格注释告诉编译器忽略 <code><b>//</b></code> 和换行符之间的所有内容。
</p>
<h3><span class="editsection">[<a href="/mwiki/index.php?title=cpp/comment&amp;action=edit&amp;section=4" title="编辑章节：注解">编辑</a>]</span> <span class="mw-headline" id=".E6.B3.A8.E8.A7.A3">注解</span></h3>
<p>因为注释在预处理器阶段前已经<a href="/w/cpp/language/translation_phases#.E9.98.B6.E6.AE.B5_3" title="cpp/language/translation phases">被移除</a>，所以宏不能用于组成注释，而且未终止的 C 风格注释不会从被 #include 的文件中漏出。
</p><p>除了把代码注释掉之外，用于排除源代码的其他机制还有：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#if 0</span>
    <a href="http://zh.cppreference.com/w/cpp/io/cout"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">&quot;这一句不会被执行，甚至不会被编译<span class="es1">\n</span>&quot;</span><span class="sy4">;</span>
<span class="co2">#endif</span></pre></div></div>
<p>以及
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw2">false</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    <a href="http://zh.cppreference.com/w/cpp/io/cout"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">&quot;这一句不会被执行<span class="es1">\n</span>&quot;</span><span class="sy4">;</span>
<span class="br0">&#125;</span></pre></div></div>
<h3><span class="editsection">[<a href="/mwiki/index.php?title=cpp/comment&amp;action=edit&amp;section=5" title="编辑章节：示例">编辑</a>]</span> <span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;iostream&gt;</span>
&#160;
<span class="coMULTI">/* C 风格注释
能含有多行 */</span>
<span class="coMULTI">/* 或只有一行 */</span>
&#160;
<span class="coMULTI">/**************
 *  你能插入任意数量的 *，
 *  但你不能嵌套注释
 */</span>
&#160;
<span class="co1">// C++ 风格注释能注释一行</span>
&#160;
<span class="co1">// 或者，能将</span>
<span class="co1">// 它们串在一起</span>
&#160;
<span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    <span class="co1">// 注释在预处理前被移除，</span>
    <span class="co1">// 故 ABC 为 1，而非 1//2134 ，</span>
    <span class="co1">// 而 &quot;1 hello world&quot;将得以打印</span>
<span class="co2">#define ABC 1//2134</span>
    <a href="http://zh.cppreference.com/w/cpp/io/cout"><span class="kw1762">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> ABC <span class="sy1">&lt;&lt;</span> <span class="st0">&quot; hello world<span class="es1">\n</span>&quot;</span><span class="sy4">;</span>
&#160;
    <span class="co1">// 下方代码不会运行</span>
    <span class="co1">// return 1;</span>
&#160;
    <span class="co1">// 下方代码会运行</span>
    <span class="kw1">return</span> <span class="nu0">0</span><span class="sy4">;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">1 hello world</pre></div></div> 
</div>
<h3><span class="editsection">[<a href="/mwiki/index.php?title=cpp/comment&amp;action=edit&amp;section=6" title="编辑章节：参阅">编辑</a>]</span> <span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td colspan="2"> <div class="t-dsc-see"><span class=""><span>注释</span></span> 的 <span><a href="/w/c/comment" title="c/comment"><b>C 文档</b></a></span></div>
</td></tr>

</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 2531/1000000
Preprocessor generated node count: 6226/1000000
Post‐expand include size: 129049/4194304 bytes
Template argument size: 13665/4194304 bytes
Highest expansion depth: 16/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:1567-0!*!0!!zh!*!zh!* and timestamp 20241030202337 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/comment&amp;oldid=91429">https://zh.cppreference.com/mwiki/index.php?title=cpp/comment&amp;oldid=91429</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <div id='catlinks' class='catlinks catlinks-allhidden'></div>                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul>
<li id="n-mainpage-description"><a href="/w/%E9%A6%96%E9%A1%B5" title="访问首页 [z]" accesskey="z">首页</a></li><li id="n-portal"><a href="/w/Cppreference:%E7%A4%BE%E5%8C%BA%E4%B8%BB%E9%A1%B5" title="关于本项目，你可以做什么，在哪里找到你需要的事物">社区主页</a></li><li id="n-currentevents"><a href="/w/Cppreference:%E6%96%B0%E9%97%BB%E5%8A%A8%E6%80%81" title="查看当前事件的背景信息">新闻动态</a></li><li id="n-recentchanges"><a href="/w/Special:%E6%9C%80%E8%BF%91%E6%9B%B4%E6%94%B9" title="本wiki的最近更改列表 [r]" accesskey="r">最近更改</a></li><li id="n-randompage"><a href="/w/Special:%E9%9A%8F%E6%9C%BA%E9%A1%B5%E9%9D%A2" title="载入一个随机页面 [x]" accesskey="x">随机页面</a></li><li id="n-help"><a href="/w/Help:%E7%9B%AE%E5%BD%95" title="查找帮助的地方">帮助</a></li>            </ul>
        </div>
                        <div id="cpp-toolbox">
            <h5><span>工具箱</span><a href="#"></a></h5>
            <ul>
<li id="t-whatlinkshere"><a href="/w/Special:%E9%93%BE%E5%85%A5%E9%A1%B5%E9%9D%A2/cpp/comment" title="所有链入本页的wiki页面列表 [j]" accesskey="j">链入页面</a></li><li id="t-recentchangeslinked"><a href="/w/Special:%E9%93%BE%E5%87%BA%E6%9B%B4%E6%94%B9/cpp/comment" title="本页链入的页面的最近更改 [k]" accesskey="k">相关更改</a></li><li id="t-upload"><a href="http://upload.cppreference.com/w/Special:Upload" title="上传文件 [u]" accesskey="u">上传文件</a></li><li id="t-specialpages"><a href="/w/Special:%E7%89%B9%E6%AE%8A%E9%A1%B5%E9%9D%A2" title="所有特殊页面的列表 [q]" accesskey="q">特殊页面</a></li><li id="t-print"><a href="/mwiki/index.php?title=cpp/comment&amp;printable=yes" rel="alternate" title="本页面的可打印版本 [p]" accesskey="p">打印版本</a></li><li id="t-permalink"><a href="/mwiki/index.php?title=cpp/comment&amp;oldid=91429" title="本页面该版本的永久链接">永久链接</a></li><li id="t-info"><a href="/mwiki/index.php?title=cpp/comment&amp;action=info">页面信息</a></li>            </ul>
        </div>
                        <div id="cpp-languages">
            <div><ul><li>其他语言</li></ul></div>
            <div><ul>
<li class="interwiki-de"><a href="http://de.cppreference.com/w/cpp/comment" title="cpp/comment" lang="de" hreflang="de">Deutsch</a></li><li class="interwiki-en"><a href="http://en.cppreference.com/w/cpp/comment" title="cpp/comment" lang="en" hreflang="en">English</a></li><li class="interwiki-es"><a href="http://es.cppreference.com/w/cpp/comment" title="cpp/comment" lang="es" hreflang="es">Español</a></li><li class="interwiki-fr"><a href="http://fr.cppreference.com/w/cpp/comment" title="cpp/comment" lang="fr" hreflang="fr">Français</a></li><li class="interwiki-it"><a href="http://it.cppreference.com/w/cpp/comment" title="cpp/comment" lang="it" hreflang="it">Italiano</a></li><li class="interwiki-ja"><a href="http://ja.cppreference.com/w/cpp/comment" title="cpp/comment" lang="ja" hreflang="ja">日本語</a></li><li class="interwiki-ko"><a href="http://ko.cppreference.com/w/cpp/comment" title="cpp/comment" lang="ko" hreflang="ko">한국어</a></li><li class="interwiki-pl"><a href="http://pl.cppreference.com/w/cpp/comment" title="cpp/comment" lang="pl" hreflang="pl">Polski</a></li><li class="interwiki-pt"><a href="http://pt.cppreference.com/w/cpp/comment" title="cpp/comment" lang="pt" hreflang="pt">Português</a></li><li class="interwiki-ru"><a href="http://ru.cppreference.com/w/cpp/comment" title="cpp/comment" lang="ru" hreflang="ru">Русский</a></li>            </ul></div>
        </div>
            <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2024年5月28日 (星期二) 21:53。</li>
                            </ul>
                    <ul id="footer-places">
                                    <li id="footer-places-privacy"><a href="/w/Cppreference:%E9%9A%90%E7%A7%81%E6%9D%83%E6%94%BF%E7%AD%96" title="Cppreference:隐私权政策">隐私政策</a></li>
                                    <li id="footer-places-about"><a href="/w/Cppreference:%E5%85%B3%E4%BA%8E" title="Cppreference:关于">关于cppreference.com</a></li>
                                    <li id="footer-places-disclaimer"><a href="/w/Cppreference:%E5%85%8D%E8%B4%A3%E5%A3%B0%E6%98%8E" title="Cppreference:免责声明">免责声明</a></li>
                            </ul>
                                    <ul id="footer-icons" class="noprint">
                                    <li id="footer-poweredbyico">
                                            <a href="//www.mediawiki.org/"><img src="/mwiki/skins/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>                                            <a href="http://qbnz.com/highlighter/"><img src="//upload.cppreference.com/mwiki/images/2/2b/powered_by_geshi_88x31.png" alt="Powered by GeSHi" height="31" width="88" /></a>                                            <a href="http://www.tigertech.net/referral/cppreference.com"><img src="//upload.cppreference.com/mwiki/images/9/94/powered_by_tigertech_88x31.png" alt="Hosted by Tiger Technologies" height="31" width="88" /></a>                                        </li>
                                </ul>
                        <div style="clear:both">
            </div>
            </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="https://zh.cppreference.com/mwiki/load.php?debug=false&amp;lang=zh&amp;modules=skins.cppreference2&amp;only=scripts&amp;skin=cppreference2&amp;*"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="https://zh.cppreference.com/mwiki/load.php?debug=false&amp;lang=zh&amp;modules=site&amp;only=scripts&amp;skin=cppreference2&amp;*"></script>
<!-- Served in 1.416 secs. -->
	</body>
<!-- Cached 20241030202337 -->
</html>

